package org.pcorp.battlespace.modele;

public class Coordonne {
	private int x;
	private int y;
	private int z;
	
	public Coordonne() {
	
	}
	
	public Coordonne(int x, int y, int z) {
		super();
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public int getX() {
		return x;
	}
	
	public void setX(int x) {
		this.x = x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setY(int y) {
		this.y = y;
	}
	
	public int getZ() {
		return z;
	}
	
	public void setZ(int z) {
		this.z = z;
	}
	
	public String toString() {
		return x +"/" + y + "/" + z;
	}
	
	public Coordonne getCap(Coordonne destination) {
		Coordonne cap = new Coordonne();
		
		cap.setX(destination.getX() - this.x);
		cap.setY(destination.getY() - this.y);
		cap.setZ(destination.getZ() - this.z);
		
		return cap;
		
	}
	
	public int calcDistance(Coordonne coord) {
		int distance = Integer.MIN_VALUE;
		
		if (distance < Math.abs((coord.getX() - x)))
			distance = Math.abs((coord.getX() - x));
	
		if (distance < Math.abs((coord.getY() - y)))
			distance = Math.abs((coord.getY() - y));
		
		if (distance < Math.abs((coord.getZ() - z)))
			distance = Math.abs((coord.getZ() - z));
		
		return distance;
	}

	public boolean equals(Coordonne coord) {
		if (coord.getX() == x && coord.getY() == y && coord.getZ() == z)
			return true;
		return false;
	}
	
	public Coordonne clone() {
		return new Coordonne(x, y, z);
	}
}
